package com.guigu.pd.work.controller;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.guigu.pd.work.entity.TransportOrderTaskEntity;
import com.guigu.pd.work.service.TransportOrderTaskService;
import com.guigu.common.utils.PageUtils;
import com.guigu.common.utils.R;



/**
 * 运单与运输任务关联表
 *
 * @author deyran
 * @email deyran@gmail.com
 * @date 2022-07-19 19:31:34
 */
@RestController
@RequestMapping("work/transportordertask")
public class TransportOrderTaskController {
    @Autowired
    private TransportOrderTaskService transportOrderTaskService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = transportOrderTaskService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
		TransportOrderTaskEntity transportOrderTask = transportOrderTaskService.getById(id);

        return R.ok().put("transportOrderTask", transportOrderTask);
    }

    @GetMapping("/gettransportorderid/{id}")
    public List<String> gettransportorderIdbytaskId(@PathVariable("id") String id){
        QueryWrapper<TransportOrderTaskEntity> queryWrapper = new QueryWrapper<TransportOrderTaskEntity>();
        queryWrapper.eq("transport_task_id",id);
        List<TransportOrderTaskEntity> transportOrderTask = transportOrderTaskService.list(queryWrapper);
        List<String> list = new ArrayList<String>();

        for (TransportOrderTaskEntity orderTask : transportOrderTask) {
            list.add(orderTask.getTransportOrderId());
        }

        return list;
    }


}
